package cn.baiyang.rocketmq.example.producer;

import cn.baiyang.rocketmq.spring.core.AbstractRocketMQSender;

import javax.annotation.Resource;

import org.apache.rocketmq.client.apis.producer.Producer;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Component;

/**
 *
 * @author hongzhu
 * @version V1.0
 * @since 2023-07-26 16:01
 */
@Component
@ConditionalOnProperty(prefix = "rocketmq-java", value = {"producer.topics"})
public class ProducerExample extends AbstractRocketMQSender {

    protected ProducerExample(@Value("${business.topic}") String topic, @Value("${business.tag}") String tag) {
        super(topic, tag);
    }

    @Resource
    @Qualifier("defaultProducer")
    @Override
    protected void setProducer(Producer producer) {
        this.producer = producer;
    }
}
